<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
        // 属性   方式
        class Car{
            //属性设置
            name = '汽车 xxx';
            price = 20000;
            // run = function(){
            //     console.log('我能行驶~~');
            // }

            //方法设置
            constructor(a,b){
                this.name = '汽车';
                this.a = a;
                this.b = b;
            }

            playMusic(){
                console.log('播放音乐');
            }
        }

        class SmartCar extends Car{
            name = '智能汽车';

            constructor(a,b,c,d){
                //子类如果存在『构造方法』, 则第一行必须要调用『super』这个函数
                super(a,b);
                this.c = c;
                this.d = d;
            }

            zhibie(){
                console.log('我可以识别事物');
            }

            playMusic(){
                console.log('我也可以播放音乐');
            }
        }

        //为实例对象添加 name 属性, 且值为 『汽车』
        // let hongqi = new Car();

        // console.log(hongqi);
        // hongqi.run();

        let xiali = new SmartCar();

        // xiali.zhibie();
        xiali.playMusic();

    </script>
</body>
</html>